from process_video import process_video
from process_video import cylindrical_projection

import tkinter as tk
from flask import Flask, render_template, Response

def display():
    window = tk.Tk()
    window.title('柱面投影程序')
    window.geometry('500x300')
    # 视频源、焦距
    var_fileName = tk.StringVar()
    var_fileName.set('rtsp://admin:abc123456789@192.168.1.64/Streaming/Channels/2')
    var_f = tk.IntVar()
    var_f.set(2800)

    # 提示信息
    tk.Label(window, text='视频源:', font=('Arial', 14)).place(x=10, y=170)
    tk.Label(window, text='焦距:', font=('Arial', 14)).place(x=10, y=210)
    tk.Label(window, text='Cylindrical Projection', font=('Arial', 16)).pack()

    # 输入窗口
    entry_fileName = tk.Entry(window, textvariable=var_fileName, font=('Arial', 14))
    entry_fileName.place(x=120, y=175)

    entry_f = tk.Entry(window, textvariable=var_f, font=('Arial', 14))
    entry_f.place(x=120, y=215)

    # 获取输入信息
    def Program_Start():
        f = var_f.get()
        fileName = var_fileName.get()
        print("开始执行！")
        process_video(fileName, verbose=2, focus=f)

    # 在窗口界面设置放置Button按键
    b = tk.Button(window, text='执行柱面投影', font=('Arial', 12), width=15, height=1, command=Program_Start)
    b.place(x=140, y=250)

    # 第6步，主窗口循环显示
    window.mainloop()

if __name__ == '__main__':
    display()